
var regex_text = /^$|^\s+$/;

function E(id) {
    return document.getElementById(id);
}

function NE(node, id) {
    return node.getElementById(id);
}

function A(elm, attr, val) {
    if (val !== undefined) {
        return elm.setAttribute(attr, val);
    }
    return elm.getAttribute(attr);
}

function RA(elm, attr) {
    elm.removeAttribute(attr);
}

function N(elm, val) {
    if (val === undefined) {
        return A(elm, "name");
    }
    return A(elm, "name", val);
}

function CE(tag) {
    return document.createElement(tag);
}

function AC(elm, child){
    elm.appendChild(child);
}

function RC(elm, child){
    elm.removeChild(child);
}

function G(field, url) {
    var fields = ((url === undefined ? window.location.search : url).substring(1)).split('&');
    for (var i = 0; i < fields.length; i++) {
        var field_value = fields[i].split('=');
        if (field_value[0] === field) {
            return field_value[1];
        }
    }
    return false;
}

function RG(field, url) {
    var fields = ((url === undefined ? window.location.search : url).substring(1)).split('&');
    for (var i = 0; i < fields.length; i++) {
        var field_value = fields[i].split('=');
        if (field_value[0] === field) {
            fields.splice(i, 1);
            i--;
        }
    }
    return '?' + fields.join('&');
}

//unused
function http_GET(field, value, url) {
    var fields = ((url === undefined ? window.location.search : url).substring(1)).split('&');
    var found = false;
    for (var i = 0; i < fields.length; i++) {
        var field_value = fields[i].split('=');
        if (field_value[0] === field) {
            field_value[1] = value;
            fields[i] = field_value.join('=');
            found = true;
            break;
        }
    }
    if (!found) {
        fields[fields.length] = field + '=' + value;
    }
    return '?' + fields.join('&');
}

function HS(id, img, show, hide){
  E(id).style.display = (E(id).style.display === "none" ? E(id).style.display = "" : E(id).style.display = "none");
  if(img !== undefined && show !== undefined && hide !== undefined){
    E(img).src = (E(id).style.display === "none" ? 'img/' + show : 'img/' + hide);
  }
}
